/**
 * Created by Administrator on 2017/12/4.
 */
import React, {PureComponent} from 'react';
import {Table, Alert, Badge, Switch, Icon,Button, InputNumber, Tooltip, Popconfirm} from 'antd';
import styles from './index.less';


export default class AdminManage extends PureComponent{
    handleTableChange = (pagination, filters, sorter) => {
        this.props.onChange(pagination, filters, sorter);
    }

    handleDelRow = (catId, pagination) => {
        this.props.onDelRow(catId, pagination);
    }
    handleEditRow = (record, pagination) => {
        this.props.onEditRow(record, pagination);
    }

    render(){
        const {data: {list, pagination}, loading} = this.props;
        const columns = [
            {
                title: '用户ID',
                dataIndex: 'user_id',
                key: 'user_id',
            }, {
                title: '用户名',
                dataIndex: 'user_name',
                key: 'user_name',
            }, {
                title: '邮箱',
                dataIndex: 'email',
                key: 'email',
            }, {
                title: '密码',
                dataIndex: 'password',
                key: 'password',
            }, {
                title: '添加时间',
                dataIndex: 'add_time',
                key: 'add_time',
            }, {
                title:'操作',
                render:(text, record) => {
                    return (
                        <Button.Group type="ghost">
                            <Button size="small" onClick={() => this.handleEdit(record)}>编辑</Button>
                            <Popconfirm title="确定要删除吗？" onConfirm={() => this.handleDelete(record)}>
                                <Button size="small">删除</Button>
                            </Popconfirm>
                        </Button.Group>
                    );
                }
            }
        ];
        const paginationProps = {
            showSizeChanger: true,
            showQuickJumper: true,
            ...pagination,
        };
        return (
            <div className={styles.standardTable}>
                <Table
                    loading={loading}
                    rowKey={record => record.user_id}
                    dataSource={list}
                    columns={columns}
                    pagination={paginationProps}
                    onChange={this.handleTableChange}
                />
            </div>
        );
    }
}
